<?php

/**
 * 
 *
 */
class Of_Amazon extends Zend_Service_Amazon 
{
  /**
   * 
   * @var SimpleXMLElement
   */
  protected $xml;
  
  /**
   * 
   * @return Of_Amazon_item
   */
  public function itemSearch(array $options)
  {
    $defaultOptions = array('ResponseGroup' => 'Small');
    $options = $this->_prepareOptions('ItemSearch', $options, $defaultOptions);
    $this->_rest->getHttpClient()->resetParameters();
    $response = $this->_rest->restGet('/onca/xml', $options);

    if ($response->isError()) {
        /**
         * @see Zend_Service_Exception
         */
        require_once 'Zend/Service/Exception.php';
        throw new Zend_Service_Exception('An error occurred sending request. Status code: '
                                       . $response->getStatus());
    }
    $body = $response->getBody();
    $xml = new SimpleXMLElement($body);
    
    $this->checkErrors($xml);
    
    return new Of_Amazon_ResultSet($xml);
  }
  
  /**
   * 
   * @return SimpleXMLElement
   */
  public function getXml()
  {
    return $this->xml;
  }
  
  public function checkErrors(SimpleXMLElement $x)
  {
    
  }
  
}